import {
  ADD,
  MINUS,
} from '../action-type'

/**
 * 用于处理 counter 的 reducer 处理函数
 */
function counter(state = { number: 0 }, action) {
  switch (action.type) {
    case ADD:
      return { number: state.number + 1 }
    case MINUS:
      return { number: state.number - 1 }
    default:
      return state
  }
}

export default counter
